<template>
	<view style="padding-top:200rpx;">
		<image class="logo_img margin_auto u-padding-top-80 u-margin-bottom-80" mode="widthFix" :src="src"></image>
		<view style="color:#3d9ca2;" class="u-text-center u-font-16 font_weight u-margin-bottom-80">龙海智慧物业系统员工端！</view>
		<view>
			<view class="input_list margin_auto u-margin-bottom-40">
				<image class="va_m u-margin-right-20" src="../../static/password.png" mode=""></image>
				<input class="dis_inl_blo va_m" v-model="form.name" placeholder="请输入员工账号" />
			</view>
			<view class="input_list margin_auto u-margin-bottom-40">
				<image class="va_m u-margin-right-20" src="../../static/user.png" mode=""></image>
				<input class="dis_inl_blo va_m" type="password" v-model="form.password" placeholder="请输入密码" />
				
			</view>
		</view>
		<button class="l_btn" shape="circle" @click="submit">登录</button>
	</view>
	
</template>

<script>
	import {
		pasLogin
	} from '@/service/loginService.js';
	import cookie from '@/util/store/cookie.js';
	export default {
		data() {
			return {
				src: 'https://resourse.cnlhjt.com/upload/20220825/626adadebbc371644096913f843b67e4.png',
				form: {
					name: '',
					password: ''
				},
				isLogin:false
			}
		},
		mounted(){
		},
		methods:{
			submit() {
				pasLogin({
					username: this.form.name,
					password: this.form.password
				}).then(res=>{
					// console.log(res);
					if(res.code == 200){
						this.$u.vuex('isLogin', true);
						this.$u.vuex('sid', res.result.id);
						this.$u.vuex('type', res.result.type);
						this.$u.vuex('username', res.result.username);
						this.$u.vuex('nickname', res.result.nickname);
						this.$u.vuex('email', res.result.email);
						this.$u.vuex('address', res.result.address);
						this.$u.vuex('phone', res.result.phone);
						this.$u.vuex('avatar', res.result.avatar);
						this.$u.vuex('name', res.result.name);
						this.$u.vuex('post', res.result.post);
						this.$u.vuex('depart', res.result.depart);
						this.$u.vuex('job_no', res.result.job_no);
						this.$u.vuex('company', res.result.company);
						this.$u.vuex('token', res.result.token);
						cookie.set('token', res.result.token);
						cookie.set('sid', res.result.id);
						cookie.set('type', res.result.type);
						// webSocket.checkOpenSocket();
						// this.error = false;
						uni.switchTab({
							url:'/pages/mainIndex/mainIndex'
						})
					}else{
						this.$u.toast(res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.logo_img{
		display: block;
		width:40%;
	}
	.input_list{
		width:90%;
		padding:20rpx 20rpx;
		border-radius: 10rpx;
		background-color: #F2F2F2;;
	}
	.input_list image{
		width:30rpx;
		height:40rpx;
		margin-left:20rpx;
	}
	.l_btn{
		width:90%;
		height:70rpx !important;
		padding:0;
		line-height: 70rpx;
		border-radius: 35rpx;
		font-size: 30rpx;
		color:#fff;
		// border-radius: 30rpx !important;
		margin-top:120rpx;
		// background-color: #006971;
		background-image: url('https://resourse.cnlhjt.com/upload/20220825/d1aa35c1d129137d9b12c8f34e59c5bc.png');
		background-size: 100% 70rpx;
		border:none !important;
	}
</style>
